package com.xishu.entity.customer;

import com.xishu.annotation.dao.*;
import com.xishu.annotation.oplog.OplogAnnotation;
import com.xishu.entity.AbstractEntity;
import com.xishu.entity.oplog.OpName;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;

import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

@Api(description = "会员")
@Entity(name = "customer")
@Table(indexes = {@Index(columnList = "name"), @Index(columnList = "companyId"), @Index(columnList = "phone"), @Index(columnList = "email"), @Index(columnList = "vipEndTime")})
public class Customer extends AbstractEntity implements OpName {
    @Transient
    private String opName;

    @ApiModelProperty(value = "如果是电话号码注册的，那么是电话号码，如果是邮箱注册的，那么是邮箱，如果两个都是，那么是电话号码")
    private String name;

    @ApiModelProperty(value = "电话号码")
    @OplogAnnotation(fieldName = "电话号码")
    private String phone;

    @ApiModelProperty(value = "区号")
    @OplogAnnotation(fieldName = "区号")
    private String areaCode;

    @ApiModelProperty(value = "邮箱")
    @OplogAnnotation(fieldName = "邮箱")
    private String email;

    @ApiModelProperty(value = "密码")
    @Hidden
    private String password;

    @ApiModelProperty(value = "账户余额")
    private Double account;

    @ApiModelProperty(value = "盐值")
    @Hidden
    private String salt;

    @ApiModelProperty(value = "归属哪一个商家")
    private Long companyId;

    @ApiModelProperty(value = "昵称")
    @OplogAnnotation(fieldName = "昵称")
    private String nickName;

    @ApiModelProperty(value = "性别, 1男2女")
    @OplogAnnotation(fieldName = "性别")
    private Integer sex;

    @Transient
    @ApiModelProperty(value = "性别查询")
    @Search(in = true, fieldName = "sex")
    private List<Integer> sexList;

    @ApiModelProperty(value = "头像")
    @OplogAnnotation(fieldName = "头像")
    private String headImg;

    @ApiModelProperty(value = "出生年月日")
    @OplogAnnotation(fieldName = "出生年月日")
    private Long birthDay;

    @Transient
    @ApiModelProperty(value = "开始生日")
    @Search(gte = true, fieldName = "birthDay")
    private Long startBirthDay;

    @Transient
    @ApiModelProperty(value = "结束生日")
    @Search(lte = true, fieldName = "birthDay")
    private Long endBirthDay;

    @ApiModelProperty(value = "就餐偏好，依次写值,用于保存，显示")
    @Transient
    @FieldMapping(serialize = true, genericType = "java.lang.Integer", desField = "preferenceJson")
    @Search(bitAnd = true, fieldName = "preference")
    @OplogAnnotation(fieldName = "就餐偏好")
    @DefaultValue(defaultValue = "")
    private List<Integer> preferenceList;

    @FieldMapping(serialize = false, genericType = "java.lang.Integer", desField = "preferenceList")
    private String preferenceJson;

    @ApiModelProperty(value = "就餐偏好，用于查询的时候用，这里1个偏爱按照1位来算，比如西餐是1，中餐是10，意大利餐是100，那么同时喜欢西餐，中餐，意大利餐就是111,按位与求法，先求商，再取模")
    private Long preference;

    @ApiModelProperty(name = "是否是VIP")
    @DefaultValue(defaultValue = "false")
    @CustomerNotModify
    @OplogAnnotation(fieldName = "是否是VIP")
    private Boolean vip;

    @ApiModelProperty(value = "VIP的到期时间")
    @CustomerNotModify
    @OplogAnnotation(fieldName = "VIP的到期时间")
    private Long vipEndTime;

    @Transient
    @ApiModelProperty(value = "VIP的到期时间")
    private String vipEndDate;

    @Search(gte = true, fieldName = "vipEndTime")
    @Transient
    public Long startVipEndTime;

    @Search(lte = true, fieldName = "vipEndTime")
    @Transient
    public Long endVipEndTime;

    @ApiModelProperty(value = "积分")
    @CustomerNotModify
    @OplogAnnotation(fieldName = "积分")
    @DefaultValue(defaultValue = "0")
    private Integer score;

    @ApiModelProperty(value = "积分历史值，一直累加的")
    @CustomerNotModify
    @OplogAnnotation(fieldName = "积分历史值")
    private Integer scoreHistory;

    @ApiModelProperty(value = "会员的等级,与商家建立的等级的ID挂钩")
    @CustomerNotModify
    @OplogAnnotation(fieldName = "会员的等级")
    private Long vipLevelId;

    @Transient
    @ApiModelProperty(value = "会员的等级")
    @Search(in = true, fieldName = "vipLevelId")
    private List<Long> vipLevelList;

    @Transient
    @ApiModelProperty(value = "会员等级对应的")
    private String levelName_zh;

    @Transient
    @ApiModelProperty(value = "会员等级对应的")
    private String levelName_en;

    @ApiModelProperty(value = "会员状态，0表示正常，1表示冻结")
    @CustomerNotModify
    @DefaultValue(defaultValue = "0")
    @OplogAnnotation(fieldName = "会员状态")
    private Integer status;

    @ApiModelProperty(value = "会员状态，0表示正常, 1表示冻结")
    @Search(in = true, fieldName = "status")
    @Transient
    private List<Integer> statusList;

    @ApiModelProperty(value = "会员的二维码")
    @CustomerNotModify
    @OplogAnnotation(fieldName = "会员的二维码")
    private String qrCode;

    @ApiModelProperty(value = "会员的二维码图片")
    @CustomerNotModify
    @OplogAnnotation(fieldName = "会员的二维码图片")
    private String qrCodeImg;

    @Transient
    @ApiModelProperty(value = "续费VIP")
    private Boolean renewVip;

    @Transient
    @ApiModelProperty(value = "开始年龄")
    @Search(ignore = true)
    private Integer startAge;

    @Transient
    @ApiModelProperty(value = "结束年龄")
    @Search(ignore = true)
    private Integer endAge;

    @Transient
    @ApiModelProperty(value = "年龄计算后的开始生日时间")
    @Search(gte = true, fieldName = "birthDay")
    private Long startAgeBirthDay;

    @Transient
    @ApiModelProperty(value = "年龄计算后的结束生日时间")
    @Search(lte = true, fieldName = "birthDay")
    private Long endAgeBirthDay;

    @CustomerNotModify
    @ApiModelProperty(value = "账号当前的消费次数")
    private Integer orderNumber;

    @Transient
    @ApiModelProperty(value = "用电话号码或者邮件或者二维码查询")
    @Search(or = true, fieldList = "email,phone,qrCode", ignoreCaseField = "qrCode")
    private String phoneOrEmailOrCode;

    @Transient
    @ApiModelProperty(value = "用电话号码或者邮件模糊查询")
    @Search(orLike = true, fieldList = "email,phone")
    private String likePhoneOrEmail;

    @Transient
    @ApiModelProperty(value = "用于计数会员的邮件是否存在")
    @Search(exist = true, fieldName = "email")
    private Boolean emailExist;

    @Transient
    @ApiModelProperty(value = "用于计数会员的电话是否存在")
    @Search(exist = true, fieldName = "phone")
    private Boolean phoneExist;

    @Transient
    @ApiModelProperty(value = "旧密码")
    private String oldPassword;

    @Transient
    @ApiModelProperty(value = "检查会员账号是否正常")
    private Boolean checkCustomerStatus;

    @ApiModelProperty(value = "memberId")
    private String memberId;

    @ApiModelProperty(value = "RankExpireDate")
    private String mRankExpireDate;

    @ApiModelProperty(value = "sta")
    private String sta;

    @ApiModelProperty(value = "accountInfo")
    private String accountInfo;

    @ApiModelProperty(value = "optionalContact")
    private String optionalContact;

    @ApiModelProperty(value = "scondaryInfo")
    private String scondaryInfo;

    @ApiModelProperty(value = "registerInfo")
    private String registerInfo;

    @ApiModelProperty(value = "deliveryAddress")
    private String deliveryAddress;

    @ApiModelProperty(value = "payMethod")
    private String payMethod;

    @ApiModelProperty(value = "loginMethod")
    private String loginMethod;

    @ApiModelProperty(value = "census")
    private String census;

    @ApiModelProperty(value = "favors")
    private String favors;

    @ApiModelProperty(value = "rank")
    private String mRank;


    public String getmRankExpireDate() {
        return mRankExpireDate;
    }

    public void setmRankExpireDate(String mRankExpireDate) {
        this.mRankExpireDate = mRankExpireDate;
    }

    public String getmRank() {
        return mRank;
    }

    public void setmRank(String mRank) {
        this.mRank = mRank;
    }

    public String getMemberId() {
        return memberId;
    }

    public void setMemberId(String memberId) {
        this.memberId = memberId;
    }

    public Double getAccount() {
        return account;
    }

    public void setAccount(Double account) {
        this.account = account;
    }

    public String getSta() {
        return sta;
    }

    public void setSta(String sta) {
        this.sta = sta;
    }

    public String getAccountInfo() {
        return accountInfo;
    }

    public void setAccountInfo(String accountInfo) {
        this.accountInfo = accountInfo;
    }

    public String getOptionalContact() {
        return optionalContact;
    }

    public void setOptionalContact(String optionalContact) {
        this.optionalContact = optionalContact;
    }

    public String getScondaryInfo() {
        return scondaryInfo;
    }

    public void setScondaryInfo(String scondaryInfo) {
        this.scondaryInfo = scondaryInfo;
    }

    public String getRegisterInfo() {
        return registerInfo;
    }

    public void setRegisterInfo(String registerInfo) {
        this.registerInfo = registerInfo;
    }

    public String getDeliveryAddress() {
        return deliveryAddress;
    }

    public void setDeliveryAddress(String deliveryAddress) {
        this.deliveryAddress = deliveryAddress;
    }

    public String getPayMethod() {
        return payMethod;
    }

    public void setPayMethod(String payMethod) {
        this.payMethod = payMethod;
    }

    public String getLoginMethod() {
        return loginMethod;
    }

    public void setLoginMethod(String loginMethod) {
        this.loginMethod = loginMethod;
    }

    public String getCensus() {
        return census;
    }

    public void setCensus(String census) {
        this.census = census;
    }

    public String getFavors() {
        return favors;
    }

    public void setFavors(String favors) {
        this.favors = favors;
    }

    public Boolean getCheckCustomerStatus() {
        return checkCustomerStatus;
    }

    public void setCheckCustomerStatus(Boolean checkCustomerStatus) {
        this.checkCustomerStatus = checkCustomerStatus;
    }

    public String getOldPassword() {
        return oldPassword;
    }

    public void setOldPassword(String oldPassword) {
        this.oldPassword = oldPassword;
    }

    public String getLikePhoneOrEmail() {
        return likePhoneOrEmail;
    }

    public void setLikePhoneOrEmail(String likePhoneOrEmail) {
        this.likePhoneOrEmail = likePhoneOrEmail;
    }

    public Boolean getEmailExist() {
        return emailExist;
    }

    public void setEmailExist(Boolean emailExist) {
        this.emailExist = emailExist;
    }

    public Boolean getPhoneExist() {
        return phoneExist;
    }

    public void setPhoneExist(Boolean phoneExist) {
        this.phoneExist = phoneExist;
    }

    public String getPhoneOrEmailOrCode() {
        return phoneOrEmailOrCode;
    }

    public void setPhoneOrEmailOrCode(String phoneOrEmailOrCode) {
        this.phoneOrEmailOrCode = phoneOrEmailOrCode;
    }

    public Integer getOrderNumber() {
        return orderNumber;
    }

    public void setOrderNumber(Integer orderNumber) {
        this.orderNumber = orderNumber;
    }

    public Long getStartAgeBirthDay() {
        return startAgeBirthDay;
    }

    public void setStartAgeBirthDay(Long startAgeBirthDay) {
        this.startAgeBirthDay = startAgeBirthDay;
    }

    public Long getEndAgeBirthDay() {
        return endAgeBirthDay;
    }

    public void setEndAgeBirthDay(Long endAgeBirthDay) {
        this.endAgeBirthDay = endAgeBirthDay;
    }

    public List<Integer> getStatusList() {
        return statusList;
    }

    public void setStatusList(List<Integer> statusList) {
        this.statusList = statusList;
    }

    public Integer getStartAge() {
        return startAge;
    }

    public void setStartAge(Integer startAge) {
        this.startAge = startAge;
    }

    public Integer getEndAge() {
        return endAge;
    }

    public void setEndAge(Integer endAge) {
        this.endAge = endAge;
    }

    public Long getStartVipEndTime() {
        return startVipEndTime;
    }

    public void setStartVipEndTime(Long startVipEndTime) {
        this.startVipEndTime = startVipEndTime;
    }

    public Long getEndVipEndTime() {
        return endVipEndTime;
    }

    public void setEndVipEndTime(Long endVipEndTime) {
        this.endVipEndTime = endVipEndTime;
    }

    public String getLevelName_zh() {
        return levelName_zh;
    }

    public void setLevelName_zh(String levelName_zh) {
        this.levelName_zh = levelName_zh;
    }

    public String getLevelName_en() {
        return levelName_en;
    }

    public void setLevelName_en(String levelName_en) {
        this.levelName_en = levelName_en;
    }

    public Boolean getRenewVip() {
        return renewVip;
    }

    public void setRenewVip(Boolean renewVip) {
        this.renewVip = renewVip;
    }

    public String getQrCode() {
        return qrCode;
    }

    public void setQrCode(String qrCode) {
        this.qrCode = qrCode;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public Long getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Long companyId) {
        this.companyId = companyId;
    }

    public Integer getScoreHistory() {
        return scoreHistory;
    }

    public void setScoreHistory(Integer scoreHistory) {
        this.scoreHistory = scoreHistory;
    }

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer score) {
        this.score = score;
    }

    public Long getVipLevelId() {
        return vipLevelId;
    }

    public void setVipLevelId(Long vipLevelId) {
        this.vipLevelId = vipLevelId;
    }

    public Boolean getVip() {
        return vip;
    }

    public void setVip(Boolean vip) {
        this.vip = vip;
    }

    public Long getVipEndTime() {
        return vipEndTime;
    }

    public void setVipEndTime(Long vipEndTime) {
        this.vipEndTime = vipEndTime;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    public String getHeadImg() {
        return headImg;
    }

    public void setHeadImg(String headImg) {
        this.headImg = headImg;
    }

    public Long getBirthDay() {
        return birthDay;
    }

    public void setBirthDay(Long birthDay) {
        this.birthDay = birthDay;
    }

    public Long getPreference() {
        return preference;
    }

    public void setPreference(Long preference) {
        this.preference = preference;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAreaCode() {
        return areaCode;
    }

    public void setAreaCode(String areaCode) {
        this.areaCode = areaCode;
    }

    public List<Integer> getSexList() {
        return sexList;
    }

    public void setSexList(List<Integer> sexList) {
        this.sexList = sexList;
    }

    public Long getStartBirthDay() {
        return startBirthDay;
    }

    public void setStartBirthDay(Long startBirthDay) {
        this.startBirthDay = startBirthDay;
    }

    public Long getEndBirthDay() {
        return endBirthDay;
    }

    public void setEndBirthDay(Long endBirthDay) {
        this.endBirthDay = endBirthDay;
    }

    public List<Integer> getPreferenceList() {
        return preferenceList;
    }

    public void setPreferenceList(List<Integer> preferenceList) {
        this.preferenceList = preferenceList;
    }

    public String getPreferenceJson() {
        return preferenceJson;
    }

    public void setPreferenceJson(String preferenceJson) {
        this.preferenceJson = preferenceJson;
    }

    public List<Long> getVipLevelList() {
        return vipLevelList;
    }

    public void setVipLevelList(List<Long> vipLevelList) {
        this.vipLevelList = vipLevelList;
    }

    public String getVipEndDate() {
        return vipEndDate;
    }

    public void setVipEndDate(String vipEndDate) {
        this.vipEndDate = vipEndDate;
    }

    public String getQrCodeImg() {
        return qrCodeImg;
    }

    public void setQrCodeImg(String qrCodeImg) {
        this.qrCodeImg = qrCodeImg;
    }

    @Override
    public void setOpName(String str) {
        this.opName = str;
    }

    @Override
    public String getOpName() {
        return opName;
    }

    @Override
    public String opType() {
        return "会员账号";
    }

    @Override
    public String[] fieldName() {
        return new String[]{"name"};
    }
}
